The present invention relates to a rational number operation unit for reducing a rational number.
Numerals handled in a computer have been, in many cases, integers and real numbers, but in a recent computer, a mathematical formula is handled and an operation to a rational number is required in a certain application field.
An operation instruction handled in the computer usually specified an operation code, a first operand and a second operand and the specified operation is carried out for those operands. The add/subtract/multiply/divide operations of rational numbers can be theoretically carried out only by combination of operations of integers. For example, when the first operand is a/b and the second operand is c/d (where a, b, c and d are integers), the add/subtract/multiply/divide operations are carried out in the following manner. A result of addition is (ad+bc)/bd, a result of subtraction is (ad-bd)/bd, a result of multiplication is ac/bd and a result of division is ad/bc. In the computer, the numbers of digits of numerator and denominator are frequently limited. The numbers of digits of the numerator and denominator of the results of the add/subtract/multiply/divide operations may be within the limit and a result of operation may not be within the limit. For example, in the addition, if both the denominators b and d are m digits, the product b.d thereof is of 2m digits which is not within the limit m.
A method to render both the numerator and denominator no longer than the predetermined number of digits is to reduce the numerator and denominator. In a known method to reduce the rational number, a greatest common measure of the numerator and denominator is determined by an Euclid mutual division method and the numerator and denominator are divided by the greatest common measure. In this method, the reduction is principally possible but since the number of times of division is large, it is not a practical method. It cannot attain a high speed operation.